<div class = "main-view">
    <div class="left-margin top-margin"><strong class="am-text-primary am-text-lg">二手管理</strong></div>
    <form class="am-form-inline left-margin top-margin" role="form">

        <div class="city-cascading" style="display: inline-block;" id="cascad-search"></div>

        <div class="am-form-group">
            <label><b>闲置/服务:</b></label>
            <select style="height: 32px" ng-model="itemType">
                <option value=''>全部</option>
                <option value=1>闲置</option>
                <option value=2>服务</option>
            </select><br/>

            <label>用户ID:</label>
            <input type="text"  class="am-form-field" style="height: 32px" placeholder=""  ng-model="createdBy">
            <label>用户昵称:</label>
            <input type="text"  class="am-form-field" style="height: 32px" placeholder=""  ng-model="nickName">
            <label>用户手机:</label>
            <input type="text"  class="am-form-field" style="height: 32px" placeholder=""  ng-model="phone">

            <!--<label style="width:75px">描述:</label> <input type="text" class="am-form-field"ng-model="Title" >-->

            <!--<label>交易类型:</label>-->
            <!--<select ng-model="type">-->
                <!--<option value=''>全部</option>-->
                <!--<option value=1>二手</option>-->
                <!--<option value=2>免费</option>-->
            <!--</select>-->
            <label class="left-margin">商品类别:</label>
            <select style="height: 32px" ng-model="category">
                <option value=''>全部</option>
                <option ng-repeat="c in categoryList" value="{{c.objId}}">{{itemTypeWord[c.itemType]}}: {{c.name}}</option>

            </select>
            <label>交易状态:</label>
            <select style="height: 32px" ng-model="dealStatus">
                <option value=''>全部</option>
                <option value=0>未交易</option>
                <option value=1>已交易</option>
            </select>
            <label>商品等级:</label>
            <select style="height: 32px" ng-model="level">
                <option value=''>全部</option>
                <option value=0>普通</option>
                <option value=1>推荐</option>
            </select>
        </div>
        <br><br>
        <div  class="am-form-group">

            <label style="width:58px">标题:</label> <input type="text" class="am-form-field" style="height: 32px" ng-model="title" >

            <label style="width:58px">价格:</label> <input type="text" class="am-form-field" style="height: 32px" ng-model="floorPrice" >
            <label style="width:10px">-</label> <input type="text" class="am-form-field" style="height: 32px" ng-model="topPrice" >

            <label>发布时间:</label>
            <input type="text" id="startDate" class="datepicker" size="12"  style="height: 32px" data-date-format="yyyy-mm-dd">
            <label>至：</label>
            <input type="text" id="endDate" class="datepicker" size="12" style="height: 32px" sdata-date-format="yyyy-mm-dd">
            <label class="left-margin">排序方式:</label>
            <select ng-model="sort">
                <option value=''>发布时间</option>
                <option value='1'>价格从高到低</option>
                <option value='2'>价格从低到高</option>
            </select>
        </div>
        <br><br>
        <div  class="am-form-group">
            <label class="left-margin">是否闪购:</label>
            <select ng-model="sale">
                <option value=''>全部</option>
                <option value=1>是</option>
                <option value=0>否</option>
            </select>
        </div>
        <button  id="search-target" type="submit" class="am-btn am-btn-primary" ng-click="search($event)" data-target = "cascad-search">搜索</button>
    </form>
    <br>
    <div class="am-btn-group am-btn-group-xs left-margin top-margin">
        <!--<button type="button" class="am-btn am-btn-default" data-am-modal="{target: '#doc-modal-add', width: 800, height: 600}"><span class="am-icon-plus"></span>添加二手</button>-->
        <button type="button" class="am-btn am-btn-default" ng-click="delete()"><span class="am-icon-trash-o"></span> 删除</button>
        <button type="button" class="am-btn am-btn-default" ng-click="exportGoods()"><span class="am-icon-download"></span> 导出</button>
    </div>
    <div id="pagination" class="pagination"></div>
    <!--<div class = "left-margin">共<span id = 'page_number1'>{{pageNumber}}</span>页 <span>{{count}}条数据</span></div>-->
    <div class="pagination-table left-margin" id="tab_menu" style = "margin-top: 0px;">
        <form class="am-form">
            <table class="am-table am-table-striped am-table-hover table-main">
                <thead>
                <tr>
                    <th class="table-check"><input type="checkbox" ng-click="allSelected()"></th>
                    <th class="table-title">用户ID</th>
                    <th class="table-title">用户所在城市</th>
                    <th class="table-title">用户所属小区</th>
                    <!--<th class="table-title">用户ID</th>-->
                    <th class="table-title">用户创建日期</th>
                    <th class="table-title">用户昵称</th>
                    <th class="table-title">用户手机</th>
                    <th class="table-title">标题	</th>
                    <th class="table-title">描述</th>
                    <th class="table-title">图片数</th>
                    <th class="table-title">类别</th>
                    <th class="table-title">闲置/服务</th>
                    <th class="table-title">回复/数量</th>
                    <th class="table-title">价格</th>
                    <th class="table-title">原价</th>
                    <th class="table-title">类别</th>
                    <th class="table-title">是否成交</th>
                    <th class="table-title">发布时间</th>
                    <th class="table-title">创建时间</th>
                    <th class="table-title">操作</th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="goods in goodsList"  id = "{{goods.objId}}">
                    <td class="table-check"><input type="checkbox" class = "item-check"></td>
                    <td>{{goods.createdBy.objId}}</td>
                    <td>{{goods.city.name}}</td>
                    <td>{{goods.community.communityName}}</td>
                    <td>{{goods.createdBy.dateCreated | date:'yyyy-MM-dd' }}</td>
                    <td>{{goods.createdBy.nickName}}</td>
                    <td>{{goods.createdBy.mobilePhone}}</td>
                    <td>{{goods.title}}</td>
                    <td style="width: 400px;word-wrap:break-word;"><div style = "position: relative;width: 400px;line-height: 1.2;">{{goods.desc}}</div></td>
                    <td>{{goods.images.length}}</td>
                    <td>{{goods.type==1? '不免费':'免费'}}</td>
                    <td>{{itemTypeWord[goods.itemType]}}</td>
                    <td>
                        <div class = "ell" style = "width: 70px;line-height: 1.2;"><a href="javascript:void(0)" id="resModal{{$index}}" ng-click="replieCount(goods)">查看</a>/
                            {{goods.replyCount}}
                        </div>
                    </td>
                    <td>{{goods.presentPrice}}</td>
                    <td>{{goods.originalPrice}}</td>
                    <td>{{goods.category.name}}</td>
                    <td>{{goods.dealStatus ? '已交易':'未交易'}}</td>
                    <!--<td>{{}}</td>-->
                    <!--<td>{{question.createdBdealStatusy.nickName}}</td>>-->
                    <td><div>{{goods.releaseDate | date:'yyyy-MM-dd'}}<br>{{goods.releaseDate | date:'HH:mm:ss'}}</div></td>
                    <td><div>{{goods.dateCreated | date:'yyyy-MM-dd'}}<br>{{goods.dateCreated | date:'HH:mm:ss'}}</div></td>
                    <!--<td>{{}}</td>-->
                    <!--<td>{{}}</td>-->
                    <td>
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                <button class="am-btn am-btn-default am-btn-xs am-text-secondary" ng-click="secondHandEdit(goods)"><span class="am-icon-copy"></span> 编辑</button>
                                <button ng-show="goods.level==0 || !goods.level" class="am-btn am-btn-default am-btn-xs am-text-secondary" ng-click="handleLevel(goods,1)"><span class="am-icon-copy"></span> 推荐</button>
                                <button ng-show="goods.level==1" class="am-btn am-btn-default am-btn-xs am-text-secondary" ng-click="handleLevel(goods,0)"><span class="am-icon-copy"></span> 取消推荐</button>
                                <button ng-show="goods.saleNumber" class="am-btn am-btn-default am-btn-xs am-text-secondary" ng-click="handleSale(goods,0)"><span class="am-icon-copy"></span> 取消闪购</button>
                            </div>
                        </div>

                    </td>
                </tr>
                </tbody>
            </table>
        </form>
    </div>
    <div class = "left-margin">共<span id = 'page_number2'>{{pageNumber}}</span>页 <span>{{count}}条数据</span></div>

    <!--编辑框 -->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-edit">
        <div class="am-modal-dialog">
            <div class="am-modal-hd border-bottom" style = "text-align: left;">编辑二手商品
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
            </div>
            <div class="am-modal-bd body-area text-left" style="margin-left: 40px ">
                <form>
                    <br>
                    <label style="width: auto">标题:</label><input class="modal-input" ng-model="updateData.title">
                    <label class="left-margin">商品类别:</label>
                    <select style="height: 32px" ng-model="updateData.category.objId">
                        <option ng-repeat="c in categoryList" value="{{c.objId}}">{{itemTypeWord[c.itemType]}}: {{c.name}}</option>
                    </select>
                    <br>
                    <label style="width: auto">类型:</label>
                    <select data-am-selected="{btnSize: 'sm'}" ng-model="updateData.type" style="margin-left: 0px;" id="type">
                        <option value=1>不免费</option>
                        <option value=2>免费</option>
                    </select>
                    <br>
                    <label class="control-label">描述：</label><br />
                    <textarea style="width:600px;height:150px;" ng-model="updateData.desc"></textarea>
                    <br><br>
                    <div class="form-group">

                        <slide ng-repeat="img in updateData.images"
                               active="img.active">
                            <img ng-src="{{img.imageURL}}" style="width: 100px;" onclick="if($(this).width()==100) {
                                                                    $('img').width(100);
                                                                    $(this).width(360);
                                                                    }else{
                                                                        $(this).width(100);
                                                                    };">
                        </slide>
                    </div>
                    <br><br>
                    <label style="width: auto">价格:</label><input class="modal-input" type="number" ng-model="updateData.presentPrice">
                    <label style="width: auto">原价:</label><input class="modal-input" type="number" ng-model="updateData.originalPrice">
                    <br>
                    <label>交易状态:</label>
                    <select style="height: 32px" ng-model="updateData.dealStatus" id="dealStatus">
                        <option ng-repeat="c in dealStatusList" value="{{c.value}}">{{c.name}}</option>

                    </select>
                </form>
            </div>
            <div class = "button-area border-top">
                <button type="button" class="am-btn am-btn-success right-margin top-margin" ng-show="true" ng-click="updateSecondHand(updateData)" data-target = "cascad-edit">保存</button>
            </div>
        </div>
    </div>

    <div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-reply">
        <div class="am-modal-dialog">
            <div class="am-modal-hd border-bottom" style = "text-align: left;">回复信息
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
            </div>


            <form class="am-form">

                <div class="form-group">
                    <slide ng-repeat="img in repGoods"
                           active="img.active">
                        <img ng-src="{{img.imageURL}}" style="width: 100px;" onclick="if($(this).width()==100) {
                                                                    $('img').width(100);
                                                                    $(this).width(360);
                                                                    }else{
                                                                        $(this).width(100);
                                                                    };">
                    </slide>
                </div>

                <table class="am-table am-table-striped am-table-hover table-main">
                    <thead>
                    <tr>
                        <!--<th class="table-check"><input type="checkbox" ng-click="allSelected()"></th>-->
                        <!--<th class="table-title">用户所在城市</th>-->
                        <th class="table-title">回复者昵称</th>
                        <th class="table-title">所在小区</th>
                        <th class="table-title">回复内容</th>
                        <th class="table-title">回复时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="reply in replyList"  id = "{{reply.objId}}">
                        <td>{{reply.repliedBy.nickName}}</td>
                        <td>{{reply.community.communityName}}</td>
                        <td>{{reply.replyDesc}}</td>
                        <td><div>{{reply.dateReplied | date:'yyyy-MM-dd HH:mm:ss'}}</div></td>
                    </tr>
                    </tbody>
                </table>
            </form>


        </div>

    </div>


</div>

<script>


    Date.prototype.format = function (format) {
        var o = {
            "M+": this.getMonth() + 1, //month
            "d+": this.getDate(), //day
            "h+": this.getHours(), //hour
            "m+": this.getMinutes(), //minute
            "s+": this.getSeconds(), //second
            "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
            "S": this.getMilliseconds() //millisecond
        }
        if (/(y+)/.test(format)) format = format.replace(RegExp.$1,
                (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o) if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1,
                    RegExp.$1.length == 1 ? o[k] :
                            ("00" + o[k]).substr(("" + o[k]).length));
        return format;
    }

    var fromDate = $('#startDate').datepicker().on('changeDate', function (ev) {
        //alert(ev.date.format('yyyy-MM-dd'));
        //$scope.startDate=ev.date.format('yyyy-MM-dd');
        $("#startDate").val(ev.date.format('yyyy-MM-dd'));
//        alert(ev.date);
    });

    var toDate = $('#endDate').datepicker().on('changeDate', function (ev) {
        // alert(ev.date.format('yyyy-MM-dd'));
        //$scope.endDate=ev.date.format('yyyy-MM-dd');
        $("#endDate").val(ev.date.format('yyyy-MM-dd'));
    });

    var hideContent = function(obj){
        $("#display_hide_content").css("display","block");
        $("#display_hide_content1").text(obj.innerText);
        $("#display_hide_content")[0].style.left = obj.offsetLeft + "px";
        $("#display_hide_content")[0].style.top = 60 + obj.offsetTop + "px";
    };

    $("#display_hide_close").on("click",function(){
        $("#display_hide_content").css("display","none");
    });

</script>